%% %This figure has been modified to generate Figure 11CD

figure(400)
close
figure(400)
hold on
set(gcf,'Name','PRIMELT3 comparison')
set(gcf, 'Units', 'Inches', 'Position',   [4.3472 6.0556 13.5278 6.9444], 'PaperUnits', 'Inches', 'PaperSize', [8.5, 11])


%subaxis(1,2,1,'Margin',.03,'Spacing',.04,'PaddingBottom',.06)
subaxis(1,2,1,'Spacing',.02,'Margin',0.015,'Padding',0.00,'PaddingLeft',0.04,'PaddingBottom',.033)

hold on



%For comparison to PRIMELTS
KnownMgNumPRIMELT=[0.75
    0.75
    0.76
    0.76
    0.72
    0.75
    0.75
    0.74];



fitness = fitlm(KnownT,MantlePotentialTemp);
fitnessR2 = fitness.Rsquared.Ordinary;
fitnessRMSE = fitness.RMSE;
text(1230,1550,sprintf('R^2=%.2f, RMSE=%.1f^oC',round(fitnessR2,2),fitnessRMSE),'FontName','Times New Roman','FontSize',15);

for aa= UniqueLabels_Rows' %1:size(runningMarkers,1)
    llkm =find(ismember(runningLabels, runningLabels(aa)));
    plot(KnownT(llkm), MantlePotentialTemp(llkm),runningMarkers{aa},'Color',eval(runningColors_LINE{aa}),'MarkerFaceColor',eval(runningColors_FILL{aa}),'MarkerSize',eval(runningSizes{aa}))
    text(KnownT(llkm), MantlePotentialTemp(llkm)-10,PM_errorStr(llkm),'HorizontalAlignment','center','VerticalAlignment','top','FontName','Times New Roman','FontSize',13)
end



legend(UniqueLabels,'FontName','Times New Roman','FontSize',15,'Location','Best')
%axis equal
box on
ax = gca;
plot([1200 1800],[1200 1800],'-k','handlevisibility','off')
axis([1200 1800 1200 1800])
plot([1200 1900],[1200 1900],'-k','handlevisibility','off')

axis([1200 1650 1200 1650])
set(gca, 'Xtick',1200:50:2000)
set(gca, 'Ytick',1200:50:2000)
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = ax.XLim(1):25:ax.XLim(2);
ax = gca;
ax.YAxis.MinorTick = 'on';
ax.YAxis.MinorTickValues = ax.YLim(1):25:ax.YLim(2);
set(gca,'ticklength',1.3*[0.0200    0.0500])
axis square

ylabel('RevPet Melting T (\circC)')
xlabel('Experiment Temperature (\circC)')
set(gcf,'Name','Experiment comparison')

ylabel('RevPet Min T_{MP} (\circC)')
xlabel('PRIMELT3 AFM T_{MP} (\circC)')
% set(gcf,'Name','PRIMELT3 comparison')

set(gca,'fontsize', 14,'LineWidth',.7,'FontName','Times New Roman')
set(gca,'XColor', 'k')
set(gca,'YColor', 'k')


subaxis(1,2,2)
axis square
hold on
yline(100*MinMgNumPrimary,'k:','RevPet Min Mg#_{PRIMARY}','LineWidth',2,'LabelHorizontalAlignment','left','handlevisibility','off');
yline(100*MaxMgNumPrimary,'k:','RevPet Max Mg#_{PRIMARY}','LineWidth',2,'LabelHorizontalAlignment','left','handlevisibility','off');


for aa= UniqueLabels_Rows'; %1:size(runningMarkers,1)
    llkm =find(ismember(runningLabels, runningLabels(aa)));
    plot(100.*KnownMgNumPRIMELT(1,llkm),100.* MgnumMelt(llkm),runningMarkers{aa},'Color',eval(runningColors_LINE{aa}),'MarkerFaceColor',eval(runningColors_FILL{aa}),'MarkerSize',eval(runningSizes{aa}))
    %text(PRIMELT3_Batch_MgNum(aa), MgnumMelt(aa),labels_PRIMELT3(aa),'HorizontalAlignment','center','VerticalAlignment','middle')
    
    text(100.*KnownMgNumPRIMELT(llkm), 100.*MgnumMelt(llkm)-.22,PM_errorStr(llkm),'HorizontalAlignment','center','VerticalAlignment','top','FontName','Times New Roman','FontSize',15)
    %plot(PRIMELT3_Frac(aa), MeltingTemp(aa),runningMarkers{aa},'Color','r','MarkerFaceColor',eval(runningColors_FILL{aa}))
    %text(PRIMELT3_Batch(aa), MeltingTemp(aa),labels_PRIMELT3(aa),'HorizontalAlignment','center','VerticalAlignment','top')
    %text(PRIMELT3_Frac(aa), MeltingTemp(aa),labels_PRIMELT3(aa),'Color','r','HorizontalAlignment','center','VerticalAlignment','top')
end





ax = gca;
%h=legend([grouplabels(highlight_ReverseFC)','above: PETROGEN hotter'],'FontName','Times New Roman','FontSize',15,'Location','Best')

%h=legend(UniqueLabels,'FontName','Times New Roman','FontSize',15,'Location','Best');

%set(h,'position',[0.4148 0.0579 0.1412 0.9225])

plot([0 100],[0 100],'-k','handlevisibility','off')
%axis([57 92 57 92])
axis([68 79 68 79])
set(gca, 'Xtick',0 :2:90)
set(gca, 'Ytick',0 :2:90)
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = ax.XLim(1):1:ax.XLim(2);
ax = gca;
ax.YAxis.MinorTick = 'on';
ax.YAxis.MinorTickValues = ax.YLim(1):1:ax.YLim(2);
set(gca,'ticklength',1.3*[0.0200    0.0500])
axis square

% ylabel('RevPet Primary Melt Mg#')
% xlabel('Experiment Primary Melt Mg#')
set(gcf,'Name','Known TP PRIMELT')

ylabel('RevPet Primary Melt Mg#')
xlabel('PRIMELT3 Primary Melt Mg#')


set(gca,'fontsize', 15,'LineWidth',.7,'FontName','Times New Roman')
set(gca,'XColor', 'k')
set(gca,'YColor', 'k')

